package com.zwj.xxljob.service.jobhandler;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Xxl任务
 */
@Component
public class TestXxlJob {
    private static final Logger logger = LoggerFactory.getLogger(TestXxlJob.class);

    @XxlJob(value = "demoJobHandler", init = "init", destroy = "destroy")
    public ReturnT<String> beanJobHandler(String param) {
        String nowtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        logger.info("Bean模式任务执行了。。。。。。" + nowtime);
        return ReturnT.SUCCESS;
    }

    public void init() {
        logger.info("前置任务init执行了。。。。");
    }

    public void destroy() {
        logger.info("后置任务destroy执行了。。。。");
    }
}
